$(function () {
    selectHeadFoot();
})

function selectHeadFoot() {
    let data = myAjax("/back/mainPage/selectHeadFoot",'','get');
    data = data.model;
    let html='';
    html+='<tr>\n' +
        '            <td>'+data.id+'</td>\n' +
        '            <td>'+data.title+'</td>\n' +
        '            <td>'+data.englishtitle+'</td>\n' +
        '            <td><img src="/back/img'+data.photo+'" width="150px"/></td>\n' +
        '            <td>'+data.foothref+'</td>\n' +
        '            <td>'+data.footwords+'</td>\n' +
        '            <td><a href="javascript:edit()">编辑</a>&nbsp;' +
        '            </td>\n' +
        '        </tr>';
    $("#findHeadFoot").html(html);

}
function edit() {
    let data = myAjax('/back/mainPage/selectHeadFoot','','get');
    data = data.model;
    let html='';
    html+='<div>系统名称：<input id="title" type="text" value='+data.title+'></div>\n' +
        '    <div>英 文 名：<textarea id="englishtitle">'+data.englishtitle+'</textarea></div>\n' +
        '    <div>图  片：<input id="photo" type="file" onclick="hide()" value='+data.photo+'/></div>\n' +
        '    <div><img id="img" src="/back/img'+data.photo+'" width="120px" style="margin-left: 52px"/></div>\n' +
        '    <div>尾部链接：<input id="foothref" type="text" value='+data.foothref+'></div>\n' +
        '    <div>尾部文字：<textarea id="footwords" style="height: 70px">'+data.footwords+'</textarea></div>\n' +
        '    <div><button onclick="updateHeadFoot()">确定修改</button></div>';
    $("#editHeadFoot").html(html);
}
function hide() {
    $("#img").attr("src","");
}
//更新HeadandFoot的信息
function updateHeadFoot() {
    let data1 = new FormData();
    data1.append("title",$("#title").val());
    data1.append("englishtitle",$("#englishtitle").val());
    data1.append("photo",$("#photo")[0].files[0]);
    data1.append("foothref",$("#foothref").val());
    data1.append("footwords",$("#footwords").val());
    let data = myFileAjax('/back/mainPage/updateHeadFoot',data1,'get');
    if (data==1){
        alert("更新成功");
    }else {
        alert("更新失败");
    }
}